package com.tang.plugin.template;

import com.tang.plugin.model.FileTreeDsl;

import java.util.HashMap;
import java.util.Map;

public class RouteTemplate {

    private static Map<String, String> fileTemplates;
    private static Map<String, String> placeHolders;

    static {
        fileTemplates = new HashMap<>();
        fileTemplates.put("build.gradle", "Template build.gradle");
        fileTemplates.put(".gitignore", "Template gitignore.gitignore");
        fileTemplates.put("AndroidManifest.xml", "Template AndroidManifest.xml");
        fileTemplates.put("ModuleApp.java", "Template ModuleApp.java");
        fileTemplates.put("ModuleService.java", "Template ModuleService.java");

        placeHolders = new HashMap<>();
        placeHolders.put("PACKAGE_NAME", "com.example");
        placeHolders.put("FEATURE_NAME", "feature");
    }

    public static final FileTreeDsl MODULE = new FileTreeDsl((n1) -> n1.addFileTemplates(fileTemplates)
            .addPlaceHolders(placeHolders)
            .placeHolder("MODULE_NAME", "NewModule")
            .dir("${MODULE_NAME}", (n2) ->
                    n2.dir("src", (n3) ->
                            n3.dir("main", (n4) ->
                                    n4.dir("java", (n5) ->
                                            n5.dir("${PACKAGE_NAME}", (n6) ->
                                                    n6.dir("${FEATURE_NAME}", (n7) ->
                                                            n7.file("ModuleApp.java").file("ModuleService.java")
                                                    )
                                            )
                                    ).include(Template.ANDROID_RES).file("AndroidManifest.xml")
                            )
                    ).file(".gitignore").file("build.gradle").file("proguard-rules.pro")
            )
    );

}
